1 /***
2 * @version $Revision: 1.1 $
3 */
4 package uba.db.sql.interpreter;
5
6 import uba.db.Database;
7 import uba.db.ar.AttributeDef;
8 import uba.db.ar.Tupla;
9 import uba.db.ar.TuplaDef;
10 import uba.db.sql.language.CreateIndex;
11 import uba.db.sql.language.IndexName;
12 import uba.db.sql.language.QualifiedColumnName;
13
14 public class CreateIndexQueryPlan implements SentenceQueryPlan {
15 CreateIndex sentence;
16
17 private boolean hasNotifiedResult;
18
19 private Database database;
20
21 private Tupla tuplaToInform;
22
23 private IndexName indexName;
24
25 private QualifiedColumnName qualifiedColumnName;
26
27 public CreateIndexQueryPlan(CreateIndex sqlSentence, Database database) {
28 sentence = sqlSentence;
29 this.database = database;
30 hasNotifiedResult = false;
31 }
32
33
34
35
36 public void startExecution() {
37 hasNotifiedResult = false;
38 sentence.accept(new CreateIndexVisitor(this));
39 try {
40
41
42 tuplaToInform = successTupla();
43 } catch (Exception e) {
44 tuplaToInform = errorTupla();
45 }
46 }
47
48
49
50
51 public boolean hasMoreResults() {
52 return (!hasNotifiedResult);
53 }
54
55 public Tupla successTupla() {
56 TuplaDef def = new TuplaDef();
57 def.addDefinition(new AttributeDef("Resultado del create index"));
58 Tupla tuple = new Tupla(def);
59 tuple.set(1, "Execución exitosa.");
60 return tuple;
61 }
62
63 public Tupla errorTupla() {
64 TuplaDef def = new TuplaDef();
65 def.addDefinition(new AttributeDef("Error"));
66 Tupla errorTuple = new Tupla(def);
67 errorTuple.set(1, "La ejecución no pudo concretarse.");
68 return errorTuple;
69 }
70
71 public Tupla nextTuple() {
72 hasNotifiedResult = true;
73 return tuplaToInform;
74 }
75
76 public String planDetail() {
77 return sentence.toString() + "\t";
78 }
79
80
81
82
83 public TuplaDef tuplaDefinition() {
84 return tuplaToInform.tuplaDefinition();
85 }
86
87 public void setIndexName(IndexName index) {
88 indexName = index;
89 }
90
91 public void setColumnName(QualifiedColumnName column) {
92 qualifiedColumnName = column;
93 }
94 }